package myjava.a_string;

/**
 * @Auther: cty
 * @Date: 2019/10/29
 * @Description: 测试字符串类内部方法
 * @version: 1.0
 */
public class A_StringMethods {
    public static void main(String[] args) {
        String s1 = "core Java";
        String s2 = "Core Java";
        System.out.println(s1.charAt(3));  //res: e  下标从0开始
        System.out.println(s1.length());  //res: 9
        System.out.println(s1.equals(s2));  //res: false
        System.out.println(s1.equalsIgnoreCase(s2));  //res: true
        System.out.println(s1.indexOf("Java"));  //res: 5
        System.out.println(s1.indexOf("apple"));  //res: -1
        System.out.println("###################################");

        String ss = "";
        String ss1 = "How are you?";
        System.out.println(ss1.startsWith("How"));  //res: true
        System.out.println(ss1.endsWith("you"));  //res: false
        System.out.println(ss1.substring(4));  //res: are you?
        System.out.println(ss1.substring(4,7));  //res: are  从0开始，左闭右开
        System.out.println(ss1.toLowerCase());  //res: how are you?
        System.out.println(ss1.toUpperCase());  //res: HOW ARE YOU?
        String ss2 = "  How are you?";
        System.out.println(ss2.trim());  //res: How are you?
        System.out.println(ss2);  //res:   How are you?
    }
}
